package com.android.porttallymansystem.ui.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.MenuItem
import android.view.View
import android.widget.LinearLayout
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import com.android.porttallymansystem.R
import com.android.porttallymansystem.databinding.ActivitySystemMessageBinding
import com.android.porttallymansystem.logic.Repository
import com.android.porttallymansystem.ui.adapter.SystemMessageAdapter

class SystemMessageActivity : AppCompatActivity() {

    private lateinit var binding: ActivitySystemMessageBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySystemMessageBinding.inflate(layoutInflater)
        setContentView(binding.root)
        setSupportActionBar(binding.toolbarSystemMessage)

        setStatusBar()

        binding.rvSystemMessage.layoutManager = LinearLayoutManager(this)
        binding.rvSystemMessage.adapter = SystemMessageAdapter(Repository.getSystemMessage())
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when (item.itemId) {
            android.R.id.home -> {
                finish()
                return true
            }
        }
        return super.onOptionsItemSelected(item)
    }

    private fun setStatusBar() {
//        window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
//                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
        window.statusBarColor = resources.getColor(R.color.green)
    }
}